// 过滤中间件
import { Next } from '../app'
import { TEST_GROUP_ID, SCREEPS_GROUP_ID, SCREEPS_NEW_GROUP_ID } from '../../constants/qq'
import { IGroupMessageEvent } from '../../interface/bot.interface'

/**
 * screeps游戏群验证
 */
export const screepsGroupVerify = (e: IGroupMessageEvent, next: Next) => {
    if (e.group_id === SCREEPS_GROUP_ID || e.group_id === TEST_GROUP_ID || e.group_id === SCREEPS_NEW_GROUP_ID) {
        return next()
    }
}

/**
 * 群消息分割
 */
export const groupMessageSplit = (e: IGroupMessageEvent, next: Next) => {
    const message = e.raw_message.split(' ')
    e.command = message[0]
    e.args = message.slice(1)
    if (e.command[0] !== '/') return
    e.command = e.command.slice(1)
    if (e.command) next()
}
